/********************************************************************
	created:	2009:12:9   22:15:19
	filename: 	playlistlistbox.h
	author:		zouyf
	describe:	
*********************************************************************/
#pragma once
#include "custommenu.h"
#include "customlistbox.h"

class FPlayListListBox : public CWindowImpl<FPlayListListBox, FCustomListBox>,
						 public COwnerDraw<FPlayListListBox>,
						 public FCustomMenu<FPlayListListBox>
{
public:
	BEGIN_MSG_MAP_EX(FPlayListListBox)
		MSG_WM_CREATE(OnCreate)
		MSG_WM_RBUTTONUP(OnRButtonUp)
		REFLECTED_COMMAND_CODE_HANDLER_EX(LBN_SELCHANGE, OnChange)
		COMMAND_ID_HANDLER_EX(ID_PLAYLIST_CIRCLE, OnClickMenuItem)
		COMMAND_ID_HANDLER_EX(ID_PLAYLIST_RAND, OnClickMenuItem)
		COMMAND_ID_HANDLER_EX(ID_PLAYLIST_SORT, OnClickMenuItem)
		COMMAND_ID_HANDLER_EX(ID_PLAYLIST_ADDSONG, OnClickMenuItem)
		COMMAND_ID_HANDLER_EX(ID_PLAYLIST_FROMFOLDER, OnClickMenuItem)
		COMMAND_ID_HANDLER_EX(ID_PLAYLIST_RENAME, OnClickMenuItem)
		COMMAND_ID_HANDLER_EX(ID_PLAYLIST_DELETE, OnClickMenuItem)
		COMMAND_ID_HANDLER_EX(ID_PLAYLIST_NEW, OnClickMenuItem)
		CHAIN_MSG_MAP_ALT(COwnerDraw<FPlayListListBox>, 1)
		CHAIN_MSG_MAP(COwnerDraw<FPlayListListBox>)
		DEFAULT_REFLECTION_HANDLER()
	END_MSG_MAP()

	int OnCreate(LPCREATESTRUCT lpCreateStruct);
	void OnClickMenuItem(UINT uNotifyCode, int nID, CWindow wndCtl);
	LRESULT OnChange(UINT uNotifyCode, int nID, CWindow wndCtl);
	void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
	void findpath(std::wstring const& path, std::wstring& ext, std::vector<std::wstring>& result);
	void OnRButtonUp(UINT nFlags, CPoint point);
	void DrawItem(LPDRAWITEMSTRUCT pDrawItem);

private:
	void InnerDrawItem(int nItem);
};
